
var ModifyImageGraphSvc = {}

ModifyImageGraphSvc.drag2Modify = function (destGraph, newTransform) {
    let pos = destGraph.getPos();
    let imgCnt = pos.getCnt();
    let PtInCtrlLocal = newTransform.destInverseMtx.MultT({ x: imgCnt.x, y: imgCnt.y, z: 0 });//求相对于控制图形局部坐标系的局部坐标
    let newWolrdPt = newTransform.newDestMtx.MultT(PtInCtrlLocal);
 
    let scale = newTransform.newDestMtx.GetS();
    let oldScaleX = destGraph.getScaleX();
    let oldScaleY = destGraph.getScaleY();
    let newScaleX = oldScaleX*scale.x;
    let newScaleY = oldScaleY*scale.y;
    let newWid = destGraph.m_width*newScaleX;
    let newHgt = destGraph.m_height*newScaleY;
    destGraph.setScaleX(newScaleX);
    destGraph.setScaleY(newScaleY);

    pos.left = newWolrdPt.x - newWid*0.5;
    pos.right = newWolrdPt.x + newWid*0.5;
    pos.bottom = newWolrdPt.y - newHgt*0.5;
    pos.top = newWolrdPt.y + newHgt*0.5;
}

export default { ModifyImageGraphSvc }